<div class="box box-left box-padding box-left-tabs">
	<div class="title">
		<h5><?php echo $this->__('Manage Discount Code');?></h5>
		<ul class="links">
			<li><a href="#box-left-forms"><?php echo $this->__("Create Batch");?></a></li>
			<li><a href="#box-left-other"><?php echo $this->__("Setup");?></a></li>
		</ul>
	</div>
	<div id="box-left-forms">
		<form method="post" id="createcouponcode" action="<?php echo App::Config()->baseUrl("/managestore/discount/createbatch");?>">
			<div class="form">
				<div class="fields">			
					<div class="field">
						<div class="label">
							<label for="batchname"><?php echo $this->__("Enter Batch Name");?></label>
						</div>
						<div class="input">
							<?php echo App::load("Helper/Html")->inputTag("data[DiscountCouponCode][batchname]","", array("id" => "batchname", "class" => "app_input check_notempty"));?>
						</div>
					</div>
					<div class="field">
						<div class="label">
							<label for="amount"><?php echo $this->__("Discount Amount:"); ?></label>
						</div>
						<div class="input">
							<?php echo App::load("Helper/Html")->inputTag("data[DiscountCouponCode][amount]", "", array("id" => "amount", "class" => "app_input check_notempty"));?>
						</div>
					</div>
					<div class="field">
						<div class="label">
							<label for="calmethod"><?php echo $this->__("Calculation Method:"); ?></label>
						</div>
						<div class="input">
							<?php echo App::load("Helper/Html")->selectTag("data[DiscountCouponCode][calmethod]",array("flatamount"=>"Flat Amount","percentage"=>"Percentage"),"flatamount", array("id" => "calmethod", "class" => "check_notempty"),array("off_blank"=>"Yes"));?>
						</div>
					</div>		
					<div class="field">
						<div class="label">
							<label for="qty"><?php echo $this->__("Quantity:"); ?></label>
						</div>
						<div class="input">
							<?php echo App::load("Helper/Html")->inputTag("data[DiscountCouponCode][qty]", "", array("id" => "qty", "class" => "app_input small check_notempty"));?>
						</div>
					</div>			
					<div class="buttons">
						<input type="submit" title="Create Batch of Codes" value="Create Batch of Codes" name="Button[create]"/>
						<input type="button" value="&lt;&lt; Back" onclick="javascript:history.go(-1)"  name="Button[Back]"/>
					</div>			
				</div>
			</div>
		</form>
	</div>
	<div id="box-left-other">
		<form method="post" id="couponcodesetting" action="<?php echo App::Config()->baseUrl("/managestore/discount/updatesetting");?>">
			<div class="form">				
				<div class="fields">
					<div class="field">
						<div class="label">
							<label for="enablediscountmodule"><?php echo $this->__("Enable Discount:"); ?></label>
						</div>
						<div class="input">
							<?php echo App::load("Helper/Html")->selectTag("data[DiscountCouponCode][enablediscountmodule]",array("Yes"=>"Yes","No"=>"No"),App::Config()->Setting('enablediscountmodule','Yes'), array("id" => "enablediscountmodule", "class" => "check_notempty"),array("off_blank"=>"Yes"));?>
						</div>
					</div>		
					<div class="field">
						<div class="label">
							<label for="rndstart"><?php echo $this->__("Random Number Generator:"); ?></label>
						</div>
						<div class="input">
						    <?php echo App::load("Helper/Html")->inputTag("data[DiscountCouponCode][discountrndstart]",App::Config()->Setting('discountrndstart',"00000000"), array("id" => "discountrndstart", "class" => "app_input small check_notempty"));?>
							-
							<?php echo App::load("Helper/Html")->inputTag("data[DiscountCouponCode][discountrndend]",App::Config()->Setting('discountrndend',"99999999"), array("id" => "discountrndend", "class" => "app_input small check_notempty"));?>
						</div>
					</div>		
					<div class="field">
						<div class="label">
							<label for="discountcodeconstant"><?php echo $this->__("Constant:"); ?></label>
						</div>
						<div class="input">
						    <?php echo App::load("Helper/Html")->inputTag("data[DiscountCouponCode][discountcodeconstant]",App::Config()->Setting('discountcodeconstant',""), array("id" => "discountcodeconstant", "class" => "app_input check_notempty"));?>						
						</div>
					</div>				
					<div class="field">
						<div class="label">
							<label for="enablediscountmodule"><?php echo $this->__("Constant Positon:"); ?></label>
						</div>
						<div class="input">
							<?php echo App::load("Helper/Html")->selectTag("data[DiscountCouponCode][discountcodeconstantpos]",array("Left"=>"Left","Right"=>"Right"),App::Config()->Setting('discountcodeconstantpos','Left'), array("id" => "discountcodeconstantpos", "class" => "check_notempty"),array("off_blank"=>"Yes"));?>
						</div>
					</div>						
					<div class="field">
						<div class="label">
							<label for="discountphpblock"><?php echo $this->__("PHP Block:"); ?></label>
						</div>
						<div class="input">
							<?php 
								echo App::Html()->textareaTag("data[DiscountCouponCode][discountcalculationphpblock]", 
								App::Config()->Setting('discountcalculationphpblock',"function calculate_discount(\$Data,\$OrdAmount){\n\n}"), 
								array(
									"id" => "discountphpblock",
									"rows"=>"10", 
									"class" => "app_input small check_notempty"
								)
							);?>
						</div>
					</div>			
					<div class="buttons">
						<input type="submit" title="Save" value="Save" name="Button[Save]"/>
						<input type="button" value="&lt;&lt; Back" onclick="javascript:history.go(-1)"  name="Button[Back]"/>
						<div class="message" style="float:right;padding-left:15px;color:green"></div>						
					</div>			
				</div>
			</div>
		</form>	
	</div>
</div>
<?php  App::Helper('JavaScript')->appForm('#createcouponcode');?>
<?php  App::Helper('JavaScript')->setAjax(array("debug" => false, "autoHide" => false))->appForm('#couponcodesetting');?>

<div class="box box-right">
	<div class="title">
		<h5><?php echo $this->__("Discount Code List");?></h5>
		<ul class="links">
			<li><a href="<?php echo App::Config()->baseUrl("/managestore/discount/downloadcsv") ?>"><?php echo $this->__("CSV");?></a></li>
			<li><a href="<?php echo App::Config()->baseUrl("/managestore/discount/downloadxml") ?>"><?php echo $this->__("XML");?></a></li>
		</ul>		
	</div>	
	<div class="form">
		<div class="fields">
		<?php if(!empty($List['data'])):?>
		<?php
			$Grid = App::Module('DataGrid')->setHeader(array("BRANCH NAME","CODE","AMOUNT","STATUS","#"));
			foreach($List['data'] as $row){
				$Grid->addRow(
					App::Html()->LinkTag(App::Config()->baseUrl("/information/manage/discountcoupon/update/{$row['id']}"),$row['batchname']),
					$row['code'],
					$row['amount'] . (($row['calmethod'] == 'percentage') ? '%' : ''),
					$row['status'],
					App::Html()->LinkTag(App::Config()->baseUrl("/information/manage/discountcoupon/update/{$row['id']}"),'Enter')
				);
			}
			$Grid->setFooter($List['paging_str'])->Render();
		?>
		<?php else:?>
			<h3 class="first warning"><?php echo $this->__("No discount code added yet");?></h3>
		<?php endif;?>
		</div>
	</div>
</div>
